package com.cdn.allmobilestore.ulti;


import android.app.Application;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;

public class NetworkChangeReceiver extends BroadcastReceiver {

	public  static boolean isConnected(boolean paramBoolean)
	{
		Application localApplication = GlobalApplication._();
		return checkNetWorkState(((ConnectivityManager)localApplication.getSystemService(Service.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(), localApplication, paramBoolean);
	}
	
	public static boolean checkNetWorkState(NetworkInfo paramNetworkInfo, Context paramContext, boolean paramBoolean)
	{
		if(paramNetworkInfo == null)
		{
			return false;
		}
		else
		{
			int networkType = paramNetworkInfo.getType();
		    int networkSubType = paramNetworkInfo.getSubtype();
		    if(networkType == ConnectivityManager.TYPE_WIFI)
		    {
		    	return true;
		    }
		    else if((networkType != ConnectivityManager.TYPE_WIFI && networkSubType != TelephonyManager.NETWORK_TYPE_UNKNOWN && networkSubType != TelephonyManager.NETWORK_TYPE_GPRS ) || networkType == ConnectivityManager.TYPE_WIMAX)
		    {
		    	if (!((TelephonyManager)paramContext.getSystemService("phone")).isNetworkRoaming())
		            return paramNetworkInfo.isConnected();
		    }
		    else
		    {
		    	return paramNetworkInfo.isConnected();
		    }
		    	
		}
		return false;
	}
	
    @Override
    public void onReceive(final Context context, final Intent intent) {
    	
    }
}